from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 1.导入鼠标操作类
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox()
driver.maximize_window()
driver.get('file:///D:/nsd2404/html/drop.html')
# 2.实例化鼠标操作类
action = ActionChains(driver)
# 源元素
src = driver.find_element(By.CSS_SELECTOR, '#div1')
# 目标元素
target = driver.find_element(By.CSS_SELECTOR, '#div2')
# 3.拖拽
action.drag_and_drop(src, target).perform()
sleep(3)
# 4.拖拽带偏移量
action.drag_and_drop_by_offset(src, xoffset=500, yoffset=300).perform()

sleep(3)
driver.quit()